var itemId = -1;
// Class Item :
function Item(name, price, usableTimes, special){
	this.name = name; 				// Name of the item (currently unused)
	this.id = (itemId += 1);		// ID for numbering the items
	this.price = price; 			// Price of it
	this.usableTimes = usableTimes; // Number of possible usage in the game (-1 = infinite)
	this.special = special;			// For object properties (currently unused)
	
	// Display the name instead of [object] (currently unused)
	// - used when a string is required
	this.toString = function(){
		return this.name;
	};
	
	// Display the Id instead of [object] (used for sorting the backpack)
	// - used when a number is required (operator+ make number required)
	this.valueOf = function(){
		return this.id;
	};

	// Get description of the item
	this.getDescription = function(){
		return '('+this.price+' gp) '+itemDescriptions[this.name];
	};
	
	// Destroy the item
	this.destroy = function(){
		WebPlayer.destroyItem(this);
	};

	// Updating an item state (used when a save is loaded)
	this.update = function(code){  //TODO
		if (true) //analyse code here
		{
			//update item
			return true;
		}
		else {
			return false;
		}
	};
	
	// Getting code state (used when saving)
	this.getState = function(code){  //TODO
		return true;	//generate the code
	};

}

var ExistingItems = [
	new Item(itemNames[0],	4,	function(){
											this.acquired = function(){};
											this.activate = function(){
												WebPlayer.assfuckSensible = false;
											};
											this.deactivate = function(){
												WebPlayer.assfuckSensible = true;
												WebPlayer.destroyItem(ExistingItems[0]);
											};
										}),
	new Item(itemNames[1],	6,	function(){
											this.acquired = function(){}; //change tables
											this.activate = function(){};
											this.deactivate = function(){};
										}),
	new Item(itemNames[2],	2,	function(){
											this.acquired = function(){
												WebPlayer.nbMaxOfItems += 2;
												ExistingItems[2].destroy(); //no other usage
											};
											this.activate = function(){};
											this.deactivate = function(){};
										}),
	new Item(itemNames[3],	4,	function(){
											this.time = 3;
											this.acquired = function(){};
											this.activate = function(){
												//remplace task by spanking
												this.time -= 1;
												if(this.time == 0){
													ExistingItems[3].destroy();
												}
											}; 
											this.deactivate = function(){};
										}),
	new Item(itemNames[4],	10,	function(){
											this.acquired = function(){};
											this.activate = function(){}; //change table
											this.deactivate = function(){};//change table
										}),
	new Item(itemNames[5],	10,	function(){
											this.acquired = function(){};
											this.activate = function(){
												WebPlayer.level += 3;
												if(WebPlayer.nbLevelUp < WebPlayer.level){
													WebPlayer.level = WebPlayer.nbLevelUp
												}
												ExistingItems[5].destroy();
											};
											this.deactivate = function(){};
										}),
	new Item(itemNames[6],	6,	function(){
											this.acquired = function(){};
											this.activate = function(){}; //change timer
											this.deactivate = function(){}; //change timer
										}),
	new Item(itemNames[7],	2,	function(){
											this.acquired = function(){};
											this.activate = function(){
												WebPlayer.facefuckSensible = false;
											};
											this.deactivate = function(){
												WebPlayer.facefuckSensible = true;
												ExistingItems[7].destroy();
											};
										}),
	new Item(itemNames[8],	6,	function(){
											this.acquired = function(){};
											this.activate = function(){};
											this.deactivate = function(){};
										}),
	new Item(itemNames[9],	2,	function(){
											this.acquired = function(){};
											this.activate = function(){
												WebPlayer.raceSensible = false;
											};
											this.deactivate = function(){
												WebPlayer.raceSensible = true;
												ExistingItems[9].destroy();
											};
										})
];